# Metview Macro

# Convert t2m to use the same grid as the first field of uv850.
# Note that the code would become more complicated if we take
# into account the different grid types (Gaussian, reduced).
# This example assumes regular lat/lon grids.

t2m   = read("t2m_forecast.grib")
uv850 = read("uv850.grib")

target_dx = grib_get_double(uv850[1], 'iDirectionIncrementInDegrees')
target_dy = grib_get_double(uv850[1], 'jDirectionIncrementInDegrees')
print(target_dx, 'x', target_dy)

new_t2m = read(data:t2m, grid:[target_dx, target_dy])
return new_t2m
